package org.example.mppg.config;


import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 自定义id生成器_推荐使用long类型存储(mysql-bigint)
 *
 * @Description CustomIdGenerator
 * @Author guoyb
 * @Date 2023/10/16 13:35
 */
@Component
@Slf4j
public class CustomIdGenerator implements IdentifierGenerator {

    @Override
    public String nextUUID(Object entity) {
        log.info("nextUUID-----打印日志-----");
        return IdUtil.getSnowflakeNextIdStr();
    }

    @Override
    public Long nextId(Object entity) {
        return IdUtil.getSnowflakeNextId();
    }
}
